Skip to content

Create env values map lazily on first define - #373

Merged
mattn merged 1 commit into
masterfrom
perf-lazy-env-map
Jul 9, 2026
Merged

Create env values map lazily on first define#373
mattn merged 1 commit into
masterfrom
perf-lazy-env-map

Conversation

@mattn

@mattn mattn commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Every scope creation (if/for blocks, function calls, try/catch) allocated a values map even when the scope never defines a symbol. Allocate it on first DefineValue instead, mirroring how the types map already works. Reads and deletes on a nil map are safe in Go.

Benchmarks: Fibonacci ~5% faster, ~3% fewer allocations; no regressions elsewhere.

@mattn
mattn merged commit eeb6179 into master Jul 9, 2026
12 checks passed
@mattn
mattn deleted the perf-lazy-env-map branch July 10, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant